package com.wyl.diy

import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.After
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Before
import org.springframework.stereotype.Component


@Aspect
@Component
class AnnotationPointCut {
    @Before("execution(* com.wyl.service.UserServiceImpl.*(..))")
    fun before() {
        println("=======方法执行前========")
    }

    @After("execution(* com.wyl.service.UserServiceImpl.*(..))")
    fun after() {
        println("=======方法执行后=========")
    }

    @Around("execution(* com.wyl.service.UserServiceImpl.*(..))")
    fun around(joinPoint: ProceedingJoinPoint) {
        println(joinPoint.signature)

        println("around前")
        val result = joinPoint.proceed()
        println(result)
        println("around后")

        /*
        void com.wyl.service.UserService.add()
        around前
        =======方法执行前========
        添加一个用户
        null
        around后
        =======方法执行后=========
         */
    }
}